package paginas;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.util.ResourceBundle;

import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import modelUtil.Configuracion;

public class MenuConfigIdiomaTab extends JPanel{

	
	

	private static final long serialVersionUID = 1L;
	private JRadioButton boton1;
	private JRadioButton boton2;
	private JRadioButton boton3;
	private JPanel panel1 = new JPanel();
	private JPanel panel2 = new JPanel();
	private JPanel panel3 = new JPanel();
	private JPanel panel4 = new JPanel();
	private FlowLayout flow1 = new FlowLayout();
	private GridLayout flow2 = new GridLayout(3,1);
	private FlowLayout flow3 = new FlowLayout();
	private FlowLayout flow4 = new FlowLayout();
	
	public MenuConfigIdiomaTab(){
		
		initComponents();
		this.setPreferredSize(new Dimension(450,450));

	}
	
	public void initComponents(){
		
		
		inicializarPaneles();
		GridBagLayout grid = new GridBagLayout();
		GridBagConstraints cons = new GridBagConstraints();

		cons.gridheight = 1;
		cons.gridwidth = 1;
		cons.fill = GridBagConstraints.BOTH;
		cons.gridx = 0;
		cons.gridy = 0;
		

		setLayout(grid);
		JLabel titulo = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma"));
		titulo.setFont(titulo.getFont().deriveFont((float)14));
		flow1.addLayoutComponent("titulo", titulo);
		panel1.add(titulo);
		grid.addLayoutComponent(panel1,cons);
		add(panel1);
		JMenu menu = new JMenu();
		cons.gridy = 1;
		grid.addLayoutComponent(panel2,cons);
		add(panel2);

		boton1 = new JRadioButton(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_castellano"));
		boton1.setFont(boton1.getFont().deriveFont((float)14));
		boton1.setFocusable(true);
		boton1.setMnemonic(KeyEvent.VK_S);
		boton1.getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_castellano"));
		boton1.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_castellano"));

		
		flow2.addLayoutComponent("boton1",boton1);
		menu.add(boton1);
		panel2.add(boton1);
		
		boton3 = new JRadioButton(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_gallego"));
		boton3.setFont(boton3.getFont().deriveFont((float)14));
		boton3.setFocusable(true);
		boton3.setMnemonic(KeyEvent.VK_G);
		boton3.getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_gallego"));
		boton3.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_gallego"));
		flow2.addLayoutComponent("boton3",boton3);
		boton3.addMouseListener(null);
		menu.add(boton3);
		panel2.add(boton3);
		
		boton2 = new JRadioButton(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_ingles"));
		boton2.setFocusPainted(false);
		boton2.setFocusable(true);
		boton2.setMnemonic(KeyEvent.VK_I);
		boton2.getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_ingles"));
		boton2.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_titulo_cambio_idioma") + ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_config_ingles"));
		boton2.setFont(boton2.getFont().deriveFont((float)14));

		
		flow2.addLayoutComponent("boton2",boton2);
		menu.add(boton2);
		panel2.add(boton2);



		ButtonGroup bg = new ButtonGroup();
		bg.add(boton1);
		bg.add(boton3);
		bg.add(boton2);
		
		String idioma = Configuracion.instancia().getIdioma();
		
		if(idioma.equals("es_ES")){
			boton1.doClick();
			boton1.setSelected(true);
		}
		if(idioma.equals("en_UK")){
			boton2.doClick();
			boton2.setSelected(true);
		}
		if(idioma.equals("gl_ES")){
			boton3.doClick();
			boton3.setSelected(true);
		}

	}

	public void inicializarPaneles(){
		

		flow1.setAlignment(FlowLayout.LEFT);
		flow3.setAlignment(FlowLayout.LEFT);
		flow4.setAlignment(FlowLayout.LEFT);
		panel1.setLayout(flow1);
		panel2.setLayout(flow2);
		panel3.setLayout(flow3);
		panel4.setLayout(flow4);

		panel1.setPreferredSize(new Dimension(400,50));
		panel3.setPreferredSize(new Dimension(400,100));
		panel2.setPreferredSize(new Dimension(400,250));



		
	}
	
	public JRadioButton getBoton1() {
		return boton1;
	}

	public void setBoton1(JRadioButton boton1) {
		this.boton1 = boton1;
	}

	public JRadioButton getBoton2() {
		return boton2;
	}

	public void setBoton2(JRadioButton boton2) {
		this.boton2 = boton2;
	}

	public JRadioButton getBoton3() {
		return boton3;
	}

	public void setBoton3(JRadioButton boton3) {
		this.boton3 = boton3;
	}
	
	
	
	
}
